package com.huawei.appgallery.appcomment.ui.view;

import android.content.Context;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.GradientDrawable;
import android.graphics.drawable.LayerDrawable;
import android.util.AttributeSet;
import android.widget.ProgressBar;
import com.huawei.appgallery.foundation.ui.css.CSSRule;
import com.huawei.appgallery.foundation.ui.css.CSSViewProxy;
import com.huawei.appgallery.foundation.ui.css.RenderListener;
import com.huawei.appgallery.foundation.ui.css.adapter.CSSPropertyName;
import com.huawei.appgallery.foundation.ui.css.adapter.type.CSSMonoColor;
import com.huawei.appgallery.foundation.ui.css.adapter.type.CSSValue;
import o.bcg.c;
import o.cgr;
import o.gg;

public class RenderProgressBar extends ProgressBar implements RenderListener {
    public RenderProgressBar(Context context) {
        super(context);
    }

    public RenderProgressBar(Context context, AttributeSet attributeSet) {
        super(context, attributeSet);
    }

    public RenderProgressBar(Context context, AttributeSet attributeSet, int i) {
        super(context, attributeSet, i);
    }

    public boolean onRenderReady(CSSViewProxy cSSViewProxy) {
        CSSRule rule = cSSViewProxy.getRule();
        if (rule.getStyleDeclaration() != null) {
            CSSValue propertyValue = rule.getStyleDeclaration().getPropertyValue(CSSPropertyName.FONT_COLOR);
            if (propertyValue != null && (propertyValue instanceof CSSMonoColor)) {
                int color = ((CSSMonoColor) propertyValue).getColor();
                setProgressDrawable(getResources().getDrawable(c.ˋॱ));
                Drawable progressDrawable = getProgressDrawable();
                if (progressDrawable != null && (progressDrawable instanceof LayerDrawable)) {
                    LayerDrawable layerDrawable = (LayerDrawable) progressDrawable.mutate();
                    Drawable findDrawableByLayerId = layerDrawable.findDrawableByLayerId(16908288);
                    if (findDrawableByLayerId instanceof GradientDrawable) {
                        ((GradientDrawable) findDrawableByLayerId).setColor(cgr.ॱ(color, 0.3f));
                        gg.ॱ(layerDrawable.findDrawableByLayerId(16908301), color);
                        setProgressDrawable(layerDrawable);
                    }
                }
            }
        }
        return false;
    }
}
